package com.wsx.ones.monitor.core.netty;

import com.wsx.ones.monitor.core.serialize.RpcSerializeProtocol;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * 管道流的操作实现
 * 该类需要必须的序列化参数，根据序列化的内容采用不同的编码解码实现类
 * Created by wangshuaixin on 17/2/6.
 */
public class PushChannelHander extends ChannelInitializer<SocketChannel> {

    private RpcSerializeProtocol protocol;

    public PushChannelHander (RpcSerializeProtocol protocol) {
        this.protocol = protocol;
    }

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //获得netty的通道，并对该通道设置相应的句柄
        ChannelPipeline pipeline = socketChannel.pipeline();
        //设置句柄的具体实现方法
        PushPipelineFrame.initPipeline(pipeline, protocol);
    }
}
